package net.techwatch.jpa.dao;

import java.util.List;

import javax.persistence.Query;

import net.techwatch.jpa.entity.Customer;

/**
 * @author wilfried
 *
 */
public class CustomerDao extends JpaDao<Long, Customer> implements ICustomerDao {

	public CustomerDao() {
		super();
	}
	
	/* (non-Javadoc)
	 * @see net.techwatch.jpa.dao.ICustomerDao#findByLastName()
	 */
	public List<Customer> findByLastName(String name) {
		Query query = getEntityManager().createNamedQuery("getPersonByLastName");
		query.setParameter(1, name);
		return query.getResultList();
	}

	/* (non-Javadoc)
	 * @see net.techwatch.jpa.dao.ICustomerDao#findByPhoneNumber()
	 */
	public List<Customer> findByPhoneNumber(String phoneNumber) {
		Query query = getEntityManager().createNamedQuery("getPersonByPhoneNumber");
		query.setParameter(1, phoneNumber);
		return query.getResultList();
	}

}
